/// <reference path="references.scss" />

.chart-colors {
    --chart-color-danger: #{$chart-color-danger};
    --chart-color-warning: #{$chart-color-warning};
    --chart-color-success: #{$chart-color-success};
    --chart-color-primary: #{$chart-color-primary};
    --chart-color-danger-light: #{$chart-color-danger-light};
    --chart-color-warning-light: #{$chart-color-warning-light};
    --chart-color-success-light: #{$chart-color-success-light};
    --chart-color-primary-light: #{$chart-color-primary-light};
    --chart-color-danger-dark: #{$chart-color-danger-dark};
    --chart-color-warning-dark: #{$chart-color-warning-dark};
    --chart-color-success-dark: #{$chart-color-success-dark};
    --chart-color-primary-dark: #{$chart-color-primary-dark};
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(10, 1fr) repeat(2, 130px);
    grid-column-gap: 1rem;
    grid-row-gap: 1rem;
    grid-auto-rows: auto;
}

.table-dashboard {
    padding-bottom: 0.75rem;

    > table {
        margin-bottom: 0;
        table-layout: fixed;

        tr > th,
        tr > td {
            border-top: 0;
            padding-left: 1rem;
            padding-right: 1rem;

            &:first-child {
                padding-inline-start: 1.5rem !important;
            }

            &:last-child {
                padding-inline-end: 1.5rem !important;
            }
        }

        tr > th {
            border-color: rgba(0,0,0, 0.05);
            border-bottom-width: 3px;
        }
    }

    > .table-3 {
        tr > th,
        tr > td {
            padding-left: 0.25rem !important;
            padding-right: 0.25rem !important;

            &:first-child {
                width: 50%;
            }

            &:last-child {
                width: 30%;
            }
        }
    }

    > .table-4 {
        tr > th,
        tr > td {
            padding-left: 0.25rem !important;
            padding-right: 0.25rem !important;

            &:nth-child(2) {
                width: 15%;
            }

            &:nth-child(4) {
                width: 15%;
            }
        }
    }
}

.report {
    background-color: white;
    border-radius: var(--border-radius-md);
    box-shadow: $box-shadow-sm;
    height: 100%;
    overflow: hidden;

    &.sticky-report {
        position: sticky;
        top: 0.625rem;
        height: auto;
    }

    .report-title-row {
        padding: 1.5rem 1.5rem 0.5rem 1.5rem;
        align-items: center;
        display: flex;
        flex-wrap: nowrap;
        row-gap: 0.5rem;

        .report-title {
            font-size: 1.25rem;
            font-weight: $font-weight-medium;
        }
    }

    .incomplete-orders-title {
        text-align: center;
        font-weight: $font-weight-medium;
        font-size: $h5-font-size;
        color: $gray-500;
    }

    .incomplete-orders-container {
        width: 100%;
        height: 100%;
        padding-top: 1rem;
    }

    .incomplete-orders-chart-container {
        width: 100%;
        height: 250px;
        position: relative;
    }

    .incomplete-orders-chart-text {
        position: absolute;
        width: 100%;
        height: 100%;
        display: flex;
        flex-flow: column;
        align-items: center;
        justify-content: center;
    }

    .incomplete-orders-quantity {
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
        max-width: 50%;
        font-weight: $font-weight-bold;
        color: $gray-500;
        font-size: 1.5rem;
        padding-bottom: .1em;
    }

    .incomplete-orders-amount {
        text-overflow: ellipsis;
        overflow: hidden;
        white-space: nowrap;
        max-width: 50%;
        font-size: 1.25rem;
        padding-top: .1rem;
        color: $gray-700;
    }

    .table {
        white-space: nowrap;

        .display-row {
            padding: .75rem 1rem;
        }

        td.display-row {
            padding: 1rem;
        }
    }

    .statistics-value {
        font-size: 1rem;
    }

    .statistics-attribute {
        color: var(--gray-600);
    }

    .statistics-container {
        width: 100%;
    }

    .statistics-content {
        display: flex;
        width: 100%;
        overflow: hidden;
        justify-content: space-between;
        border: 1px solid rgba($black, 0.05);
    }

    .statistics-col {
        display: flex;
        align-items: center;
        justify-content: center;
        border: 0;
    }

    .statistics-container-outer {
        display: flex;
        justify-content: center;
    }

    .statistics-container-inner {
        padding-inline-end: 0.5rem;
        line-height: 1.5;
    }

    .statistics-icon {
        font-size: 1.5rem;
        color: var(--gray-650);
    }

    .indicator {
        width: 10px;
        min-width: 10px;
        height: 10px;
        min-height: 10px;
        border-radius: 50%;
    }

    .btn-dashboard {
        font-size: .75rem;
        padding: .33rem .66rem;
    }

    .canvas-container {
        position: relative;
    }

    #orders-chart-legend {
        & > ul {
            cursor: pointer;
            list-style: none;
            padding: 0;
            margin: 0;
        }

        li {
            display: inline-block;
            user-select: none;

            &.hidden {
                color: $text-muted;
                user-select: none;
            }

            &.inactive {
                cursor: initial;
                text-decoration: line-through;
            }

            &:not(:last-child) {
                padding-inline-end: 1rem;
            }
        }

        .total-amount {
            text-decoration: none !important;
            display: inline-block;
            user-select: text;
        }

        .legend {
            border-radius: 50%;
            display: inline-block;
            height: 11px;
            width: 11px;
            margin-inline-end: .3rem;
        }

        .hidden > .legend {
            background-color: $gray-400 !important;
        }
    }

    .chevron {
        color: var(--success);

        &:after {
            @include fontawesome-font("\f077", regular);
            position: absolute;
        }

        &.negative:after {
            color: var(--danger);
            transform: rotate(180deg);
        }
    }

    .chart-tooltip {
        opacity: 1;
        position: absolute;
        width: fit-content;
        background: rgba(#000, 0.8);
        color: $light;
        border-radius: var(--border-radius-sm);
        transition: all 0.2s ease-in-out;
        pointer-events: none;
        transform: translateX(-50%);
        z-index: 10;
        padding: 0.4rem 0.7rem 0.5rem 0.7rem;

        &:after {
            content: "";
            position: absolute;
            width: 0;
            height: 0;
            background-color: transparent;
        }

        &.bottom:after,
        &.top:not(.right):not(.left):after {
            border-left: 9px solid transparent;
            border-right: 9px solid transparent;
            transform: translateX(-50%);
            transition: left 0.1s ease-in-out;
            inset-inline-start: 50%;
        }

        &.bottom {
            transform: translate(-50%, calc(-100% - 15px));

            &:after {
                border-top: 9px solid rgba($black, 0.8);
                top: 100%;
            }

            &.left {
                transform: translate(-10%, calc(-100% - 15px));

                &:after {
                    inset-inline-start: 10%;
                }
            }

            &.right {
                transform: translate(-90%, calc(-100% - 15px));

                &:after {
                    inset-inline-start: 90%;
                }
            }
        }

        &.top:not(.right):not(.left) {
            transform: translate(-50%, 15px);

            &:after {
                border-bottom: 9px solid rgba($black, 0.8);
                top: -9px;
            }
        }

        &.left:not(.bottom):after,
        &.right:not(.bottom):after {
            border-top: 9px solid transparent;
            border-bottom: 9px solid transparent;
            transform: translateY(-50%);
            transition: top 0.1s ease-in-out;
            top: 50%;
        }

        &.left:not(.bottom) {
            transform: translate(15px, -50%);

            &:after {
                border-inline-end: 9px solid rgba($black, 0.8);
                inset-inline-start: -9px;
            }
        }

        &.right:not(.bottom) {
            transform: translate(calc(-100% - 15px), -50%);

            &:after {
                border-inline-start: 9px solid rgba($black, 0.8);
                inset-inline-start: 100%;
            }
        }

        .chart-tooltip-indicator {
            display: inline-block;
            width: 11px;
            height: 11px;
            border-radius: 50%;
            margin-bottom: -1px;
            margin-inline-end: 0.33rem;
        }

        .chart-tooltip-title {
            font-size: $font-size-sm;
            line-height: initial;
            font-weight: $font-weight-bold;
            padding-bottom: 0.2rem;
        }

        .chart-tooltip-body {
            font-size: $font-size-xs;
            line-height: initial;

            &:not(:last-child) {
                padding-bottom: 0.1rem;
            }
        }
    }
}

.report-incomplete-orders {
    grid-column: 1 / 13;
    grid-row: 1 / 2;
}

.news-feed {
    grid-column: 1 / 13;
    grid-row: 8 / 9;
}

.report-orders {
    grid-column: 1 / 13;
    grid-row: 2 / 3;
}

.report-bestsellers {
    grid-column: 1 / 13;
    grid-row: 3 / 4;
}

.report-top-customers {
    grid-column: 1 / 13;
    grid-row: 4 / 5;
}

.report-customer-registrations {
    grid-column: 1 / 13;
    grid-row: 5 / 6;
}

.report-latest-orders {
    grid-column: 1 / 13;
    grid-row: 6 / 7;
}

.report-store-statistics {
    grid-column: 1 / 13;
    grid-row: 7 / 8;
}

@include media-breakpoint-up(sm) {
    .incomplete-orders-container {
        width: 50% !important;
    }
}

@include media-breakpoint-up(md) {
    .report-incomplete-orders {
        .incomplete-orders-container {
            width: 25% !important;
        }
    }

    .news-feed {
        grid-row: 7 / 8;
    }

    .report-orders {
        grid-row: 2 / 3;
    }

    .report-bestsellers {
        grid-column: 1 / 7;
        grid-row: 3 / 4;
    }

    .report-top-customers {
        grid-column: 7 / 13;
        grid-row: 3 / 4;
    }

    .report-customer-registrations {
        grid-row: 4 / 5;
    }

    .report-latest-orders {
        grid-row: 5 / 6;
    }

    .report-store-statistics {
        grid-row: 6 / 7;
    }
}

@include media-breakpoint-up(lg) {
    .report-incomplete-orders {
        grid-column: 1 / 11;
    }

    .news-feed {
        grid-column: 11 / -1;
        grid-row: 1 / 7;
    }

    .report-orders {
        grid-column: 1 / 11;
    }

    .report-bestsellers {
        grid-column: 1 / 5;
    }

    .report-top-customers {
        grid-column: 5 / 11;
        grid-row: 3 / 4;
    }

    .report-customer-registrations {
        grid-column: 1 / 11;
    }

    .report-latest-orders {
        grid-column: 1 / 11;
    }

    .report-store-statistics {
        grid-column: 1 / 11;
    }
}

@media screen and (min-width: 1600px) {
    .report-incomplete-orders {
        grid-column: 1 / 11;

        .incomplete-orders-chart-container {
            height: 300px;
        }
    }

    .news-feed {
        grid-column: 11 / 13;
        grid-row: 1 / 5;
    }

    .report-orders {
        grid-column: 1 / 8;
    }

    .report-bestsellers {
        grid-column: 8 / 11;
        grid-row: 2 / 3;
    }

    .report-top-customers {
        grid-column: 1 / 4;
    }

    .report-customer-registrations {
        grid-column: 4 / 11;
        grid-row: 3 / 4;
    }

    .report-latest-orders {
        grid-column: 1 / 7;
        grid-row: 4 / 5;
    }

    .report-store-statistics {
        grid-column: 7 / 11;
        grid-row: 4 / 5;
    }
}

.table-prevent-overflow {
    tr > th,
    tr > td {
        overflow-x: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
    }
}

.news-feed .report-title-row {
    padding: 1.5rem 1rem 0 1rem !important;
}

.newsfeed-body {
    padding-top: 1rem;

    .admin-config-group > .title {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .admin-config-group:after {
        inset-inline-end: 1rem;
    }
}

.newsfeed-item-title {
    margin-bottom: .5rem;
    font-weight: 600;

    & > a {
        display: block;
        line-height: 1.3;
    }
}

.cnt-newsfeed-item {
    height: 100%;
    display: flex;
    overflow: hidden;
    flex-flow: column;
    border: none;

    @include media-breakpoint-up(xs) {
        border: none;

        .newsfeed-item {
            border-bottom: 1px solid var(--gray-300);
        }
    }

    @include media-breakpoint-up(sm) {
        border: 1px solid var(--gray-300);
        border-radius: 0.375rem;

        .newsfeed-item {
            border: none;
        }
    }

    @include media-breakpoint-up(lg) {
        border: none;
        border-radius: 0;

        .newsfeed-item {
            border-bottom: 1px solid var(--gray-300);
        }
    }
}

.newsfeed-item {
    padding: 0 1rem 1.25rem 1rem;
    
    &.pinned {
        background-color: lighten($blue, 50%) !important;
    }

    .more-info {
        font-weight: 600;
    }
}

.newsfeed-thumbnail {
    min-height: 140px;
    max-height: 140px;
    max-width: 100%;
    width: 100%;
    overflow: hidden;
    display: flex;
    margin-bottom: 0;

    .file-img {
        object-fit: cover;
        width: 100%;
        height: auto;
    }
}

.btn-newsfeed {
    padding: 1.25rem 1.5rem;
}